var e = require("../../../@babel/runtime/helpers/objectWithoutProperties"), t = require("../../../@babel/runtime/helpers/defineProperty"), a = [ "url" ], i = getApp();

Page({
    data: {
        data: {},
        images: [],
        new_list: [],
        hot_list: [],
        list: {
            data: [],
            title: "推荐知识库"
        },
        keyword: "",
        plugin: "message-base",
        apiOption: {},
        itemOption: {
            article_name: "article_name",
            creater_name: "creater_name",
            base_name: "base_name",
            created_at: "created_at"
        }
    },
    onLoad: function(e) {
        this.initData(), this.getdata();
    },
    onReady: function() {},
    onShow: function() {},
    initData: function() {
        var e = this, a = new Map([ [ "message-base", {
            index: "plugin.message-base.frontend.base.firstPage",
            callback: function(a) {
                var i, n = a.data, o = n.new_list, s = n.hot_list, l = n.list, r = n.slide, d = n.keyword;
                e.setData((t(i = {
                    new_list: o,
                    hot_list: s,
                    keyword: d,
                    images: r
                }, "list.data", l.data), t(i, "list.title", "推荐知识库"), i));
            }
        } ], [ "project-template", {
            index: "plugin.project-template.frontend.knowledge.index",
            callback: function(a) {
                var i, n = a.data, o = n.knowledge_base, s = n.knowledge_base_article;
                e.setData((t(i = {
                    new_list: s
                }, "list.data", o), t(i, "list.title", "知识库"), t(i, "itemOption", {
                    article_name: "title",
                    base_name: "has_one_yz_supply_knowledge_base.title",
                    created_at: "release_time_at"
                }), i));
            }
        } ] ]);
        this.options.plu && (this.data.plugin = this.options.plu), this.setData({
            plugin: this.data.plugin,
            apiOption: a.get(this.data.plugin)
        });
    },
    getdata: function() {
        var e = this, t = i.getNetAddresss(this.data.apiOption.index);
        i._getNetWork({
            url: t,
            success: function(t) {
                1 === t.data.result ? e.data.apiOption.callback(t.data) : wx.showToast({
                    title: t.data.msg,
                    icon: "none"
                });
            }
        });
    },
    toUrl: function(e) {
        var t = e.currentTarget.dataset || {};
        this.wxRouterLink(t);
    },
    wxRouterLink: function(t) {
        var i = "", n = t.url, o = e(t, a);
        Object.keys(o).forEach(function(e) {
            "" !== o[e] && (i += e + "=" + o[e] + "&");
        }), "" !== n && wx.navigateTo({
            url: n + "?" + i.slice(0, -1)
        });
    },
    onListClick: function(e) {
        var t = e.detail, a = t.id, i = t.base_id, n = t.knowledge_base_id;
        this.wxRouterLink({
            url: "/packageI/knowledge/knowledgeDetail/knowledgeDetail",
            id: a,
            bid: i || n,
            plu: this.data.plugin
        });
    },
    onHide: function() {},
    onUnload: function() {},
    onPullDownRefresh: function() {},
    onReachBottom: function() {},
    onShareAppMessage: function() {
        var e = wx.getStorageSync("yz_uid"), t = "";
        return e && (t = e), {
            path: "/packageI/knowledge/knowledgeIndex/knowledgeIndex?plu=" + this.options.plu + "&mid=" + t
        };
    }
});